package com.mc.string;

public class BM3 {
	
	public static void main(String[] args){
		
		String pattern = "hks";
		String str = "dhksjdjkslajdkl";
		
		int[] right = new int[256];
		for(int i=0;i<pattern.length();i++){
			right[pattern.charAt(i)] = i;
		}
		int n = str.length();
		int m = pattern.length();
		int skip = 0;
		for(int i=0;i<=n-m;i+=skip){
			skip =0;
			for(int j=m-1;j>=0;j--){
				if(str.charAt(i+j)!=pattern.charAt(j)){
					skip = j-right[str.charAt(i+j)];
					if(skip<1)skip = 1;
					break;
				}
			}
			if(skip==0){
				System.out.println(true);
				return ;
			}
		}
		System.out.println(false);
	}
}
